import Koa from 'koa'
import fs from 'node:fs'

/**
 * 创建所有路由
 */
export const createRoutes = async function (app: Koa) {
  for (const file of fs.readdirSync(__dirname)) {
    if (file === 'index.ts') continue
    const router = await import(`./${file}`)
    const _router = router.default
    app.use(_router.routes())
    app.use(_router.allowedMethods())
  }
}
